
#include "bsp.h"
#include "bsp_button.h"


#define TAG "BUTTON"

#define BUTTON_PRESS_TIME  3

static void button_tap_cb(void* arg)
{
    ESP_LOGI(TAG, "button release== (%s)", (char *)arg); 
    App.Tosop_Edu_Channel++;
    ESP_LOGI(TAG, "App.Tosop_Edu_Channel=%d",App.Tosop_Edu_Channel); 
}



static void button_press_long_cb(void* arg)
{
    ESP_LOGI(TAG, "button_press_long_cb ==(%s)", (char *)arg);

    Tospo_DataBase_Save();
    ESP_LOGI(TAG, "Tospo_DataBase_Save OK!!!"); 
}



void bsp_button_init(void)
{
    gpio_config_t io_conf;

    /*
    button_handle_t btn_handle = iot_button_create(BUTTON_IO_NUM, BUTTON_ACTIVE_LEVEL);
    if (btn_handle)
    {
        iot_button_set_evt_cb(btn_handle, BUTTON_CB_RELEASE, button_tap_cb, "RELEASE");


        iot_button_add_custom_cb(btn_handle, BUTTON_PRESS_TIME, button_press_long_cb, "3");
    }
    */

   
    //disable interrupt
    io_conf.intr_type = GPIO_INTR_DISABLE;
    //set as output mode
    io_conf.mode = GPIO_MODE_OUTPUT;
    //bit mask of the pins that you want to set,e.g.GPIO18/19
    io_conf.pin_bit_mask = GPIO_OUTPUT_PIN_SEL;
    //disable pull-down mode
    io_conf.pull_down_en = 0;
    //disable pull-up mode
    io_conf.pull_up_en = 0;
    //configure GPIO with the given settings
    gpio_config(&io_conf);

    gpio_set_level(GPIO_OUTPUT_IO_0, 1);
    gpio_set_level(GPIO_OUTPUT_IO_1, 0);

    Relay_ON;
    LED_ON;





}

